import java.io.*;
import java.text.*;
import java.util.*;

public class SimpleLogger {
	private  PrintWriter _writer = null;
	
	public SimpleLogger() {
		try{_writer = new PrintWriter("output.txt");}
		catch(FileNotFoundException ex) { System.exit(-1);}
	}
	
	public void logIncoming(String msg) {
		SimpleDateFormat formatter = new SimpleDateFormat("hh:mm:ss.SS");
		String time = "time:" + formatter.format(new Date(System.currentTimeMillis())) + "\n";
		_writer.println(time + "inmsg:" + msg + "\n");
		_writer.flush();
	}
	
	public void logOutgoing(String msg) {
		SimpleDateFormat formatter = new SimpleDateFormat("hh:mm:ss.SS");
		String time = "time:" + formatter.format(new Date(System.currentTimeMillis())) + "\n";
		_writer.println(time + "outmsg:" + msg + "\n");
		_writer.flush();
	}
	
	public void logError(String msg) {
		SimpleDateFormat formatter = new SimpleDateFormat("hh:mm:ss.SS");
		String time = "time:" + formatter.format(new Date(System.currentTimeMillis())) + "\n";
		_writer.println(time + "error:" + msg + "\n");
		_writer.flush();
	}
	
	public void logCommand(String msg) {
		SimpleDateFormat formatter = new SimpleDateFormat("hh:mm:ss.SS");
		String time = "time:" + formatter.format(new Date(System.currentTimeMillis())) + "\n";
		_writer.println(time + "command:" + msg + "\n");
		_writer.flush();
	}
	
	public  void close() {
		_writer.close();
	}
}
